package com.xiaohao.communication.service;

import com.xiaohao.communication.bean.Collection;
import com.xiaohao.communication.dao.UserCollectionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserCollectionService  {

    @Autowired
    UserCollectionDao userCollectionDao;

    //获取收藏
    public List<Collection> getCollection(String username ) {
        List<Collection> collection = userCollectionDao.getCollection(username);
        return collection;
    }

    //增加收藏
    public void addCollection(Collection collection) {
        userCollectionDao.addCollection(collection);
    }


    /*
    *  删除收藏的话题
     *
    *  对于删除，前端只传送话题id，改变状态码为0；  1为存在，0为删除
    * */
    public void deleteCollection(int topic_id) {
        userCollectionDao.deleteCollection(topic_id);
    }


}
